﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace SocketClientWindowsPhone
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SocketClient client = new SocketClient();
            string resposta;
            client.Connect("10.20.2.124", 6654);
            client.Send("nomejogador/" + txtblock1.Text + "/" + txtblock2.Text);
            resposta = client.Receive();
            /*if (resposta.StartsWith("<ERRO>"))
            {
                MessageBox.Show(resposta);
            }*/

            if (resposta == "naocadastrado")
            {
                MessageBox.Show("Cliente não cadastrado ou senha inválida!");
            }
            else if (resposta == "naook")
            {
                MessageBox.Show("Cliente já está logado no sistema!");
            }
            else
            {
                NavigationService.Navigate(new Uri("/Menu.xaml", UriKind.RelativeOrAbsolute));
            }

        }
    }
}